<template>
	<view class="userpost" :class="[isDark?'dark':'', AppStyle]" :style="{'background-color':isDark?'#1c1c1c':'#f6f6f6','min-height':isDark?'100vh':'auto'}">
		<view class="header" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar" :class="isDark?'dark':'bg-white'" :style="{'height': CustomBar + 'px','padding-top':StatusBar + 'px','background-color':isDark?'#1c1c1c':'#ffffff'}">
				<view class="action" @tap="back">
					<text class="cuIcon-back"></text>
				</view>
				<view class="content text-bold" :style="[{top:StatusBar + 'px'}]">
					{{$t('manage.contents.contentmgr')}}
				</view>
			</view>
		</view>
		<view :style="[{padding:NavBar + 'px 10px 0px 10px'}]"></view>
		<view class="data-box" :class="isDark?'dark':''">
			<view class="fullpost-btn">
				<text class="cu-btn bg-blue radius" @tap="toMetas" v-if="group=='administrator'">{{$t('manage.contents.taglabel')}}</text>
			</view>
			<view class="cu-bar search" :class="isDark?'dark':'bg-white'" :style="{'background-color':isDark?'#1c1c1c':'#ffffff'}">
				<view class="search-form round">
					<text class="cuIcon-search"></text>
					<input type="text" placeholder="$t('global.gropekey')" v-model="searchText"  @input="searchTag"/>
					<view class="search-close" v-if="searchText!=''" @tap="searchClose()">
						<text class="cuIcon-close"></text>
					</view>
				</view>
			</view>
			<view class="search-type grid col-3" :class="isDark?'dark':''">
				<view class="search-type-box" @tap="toType('waiting')" :class="type=='waiting'?'active':''">
					<text>{{$t('global.approval')}}</text>
				</view>
				<view class="search-type-box" @tap="toType('publish')" :class="type=='publish'?'active':''">
					<text>{{$t('global.published')}}</text>
				</view>
				<view class="search-type-box" @tap="toType('reject')" :class="type=='reject'?'active':''">
					<text>{{$t('global.alrefused')}}</text>
				</view>
			</view>
			
			<view class="cu-card article no-card" :class="isDark?'dark':''">
				<view class="data-select" v-if="type=='publish'" :class="isDark?'dark':''">
					<text :class="dataSelect==0?'act':''" @tap="toSelect(0)">{{$t('global.all')}}</text>
					<text :class="dataSelect==1?'act':''" @tap="toSelect(1)">{{$t('global.recommend')}}</text>
					<text :class="dataSelect==2?'act':''" @tap="toSelect(2)">{{$t('global.top')}}</text>
					<text :class="dataSelect==3?'act':''" @tap="toSelect(3)">{{$t('manage.contents.carousel')}}</text>
				</view>
				<view class="no-data" v-if="contentsList.length==0" :class="isDark?'dark':''">
					<text class="cuIcon-text"></text>{{$t('common.nodata')}}
				</view>
				<view class="cu-item shadow" :class="isDark?'dark':''" v-for="(item,index) in contentsList" :key="index" :style="{'background-color':isDark?'#2a2a2a':'#ffffff'}">
					<view class="content">
						<view class="desc">
							<view class="text-content">{{item.title}}</view>
							<view>
								<view class="cu-tag bg-green light sm round" v-if="item.status=='publish'">{{$t('global.published')}}</view>
								<view class="cu-tag bg-orange light sm round" v-if="item.status=='waiting'">{{$t('global.approval')}}</view>
								<view class="cu-tag bg-red light sm round" v-if="item.status=='reject'">{{$t('global.alrefused')}}</view>
								<view class="cu-tag data-time">{{formatDate(item.created)}}</view>
							</view>
						</view>
					</view>
					<view class="manage-btn">
						<text class="text-green radius"  v-if="item.status=='waiting'" @tap="toAudit(item.cid,0)">{{$t('global.pass')}}</text>
						<text class="text-yellow radius"  v-if="item.status=='waiting'" @tap="toAudit(item.cid,1)">{{$t('global.refuse')}}</text>
						<block v-if="item.status=='publish'&&group=='administrator'">
							<text class="text-green radius" v-if="item.isrecommend==0"  @tap="addRecommend(item.cid)">{{$t('global.recommend')}}</text>
							<text class="text-grey radius" v-else  @tap="rmRecommend(item.cid)">{{$t('global.cancelrecomm')}}</text>
							<text class="text-green radius" v-if="item.istop==0"  @tap="addTop(item.cid)">{{$t('global.top')}}</text>
							<text class="text-grey radius" v-else  @tap="rmTop(item.cid)">{{$t('global.canceltop')}}</text>
							<text class="text-green radius" v-if="item.isswiper==0"  @tap="addSwiper(item.cid)">{{$t('manage.contents.carousel')}}</text>
							<text class="text-grey radius" v-else  @tap="rmSwiper(item.cid)">{{$t('global.cancelcarousel')}}</text>
							<text class="text-blue radius" @tap="setFields(item.cid,item.abcimg)">{{$t('manage.contents.textimagetype')}}</text>
						</block>
						<text class="text-blue radius" @tap="toEdit(item)">{{$t('common.edit')}}</text>
						<text class="text-red radius"  @tap="toDelete(item.cid)" v-if="group=='administrator'">{{$t('common.delete')}}</text>
						<text class="text-gray radius" style="float: right;">{{item.authorInfo.name}}</text>
					</view>
				</view>
				<view class="load-more" @tap="loadMore" v-if="contentsList.length>0" :class="isDark?'dark':''">
					<text>{{moreText}}</text>
				</view>
			</view>
		</view>
		<!--加载遮罩-->
		<view class="loading" v-if="isLoading==0" :class="isDark?'dark':''">
			<view class="loading-main">
				<image src="../../static/loading.gif"></image>
			</view>
		</view>
		<!--加载遮罩结束-->
		<view class="cu-modal" :class="modalName=='RadioModal'?'show':''" @tap="hideModal">
			<view class="cu-dialog" @tap.stop="" :class="isDark?'dark':''" :style="{'background-color':isDark?'#2a2a2a':'#ffffff'}">
				<radio-group class="block" @change="RadioChange">
					<view class="cu-list menu text-left" :class="isDark?'dark':''">
						<view class="cu-item" :class="isDark?'dark':''" v-for="(item,index) in abcimgList" :key="index">
							<label class="flex justify-between align-center flex-sub">
								<view class="flex-sub">{{item.name}}</view>
								<radio class="round" :class="abcimg==item.value?'checked':''" :checked="abcimg==item.value?true:false"
								 :value="item.value"></radio>
							</label>
						</view>
					</view>
				</radio-group>
			</view>
		</view>
		<view class="cu-modal" :class="modalName=='reject'?'show':''">
			<view class="cu-dialog" :class="isDark?'dark':''" :style="{'background-color':isDark?'#2a2a2a':'#ffffff'}">
				<view class="cu-bar justify-end" :class="isDark?'dark':'bg-white'" :style="{'background-color':isDark?'#2a2a2a':'#ffffff'}">
					<view class="content">{{$t('manage.contents.rejectreason')}}</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl text-left">
					<textarea maxlength="-1" v-model="reason" placeholder="$t('manage.contents.rejectreason')" style="width: 100%;height: 150upx;"></textarea>
				</view>
				<view class="cu-bar justify-end" :class="isDark?'dark':'bg-white'" :style="{'background-color':isDark?'#2a2a2a':'#ffffff'}">
					<view class="action">
						<button class="cu-btn line-green text-green" @tap="hideModal">{{$t('common.cancel')}}</button>
						<button class="cu-btn bg-green margin-left" @tap="toAudit(curCid,1)">{{$t('common.sure')}}</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { localStorage } from '../../js_sdk/mp-storage/mp-storage/index.js'
	import darkModeMixin from '@/utils/darkModeMixin.js'
	export default {
		mixins: [darkModeMixin],
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				NavBar:this.StatusBar +  this.CustomBar,
				AppStyle:this.$store.state.AppStyle,
				
				page:1,
				moreText:$t('common.loadmoretxt'),
				
				isLoad:0,
				token:"",
				contentsList:[],
				
				searchText:"",
				
				type:"waiting",
				
				reason:"",
				curCid:0,
				
				isLoading:0,
				
				group:"",
				
				modalName: null,
				abcimg: 'able',
				abcimgList:[
					{
						name: $t('manage.contents.default'),
						value:"able"
					},
					{
						name: $t('manage.contents.threepicture'),
						value:"mable"
					},
					{
						name: $t('manage.contents.bigpicture'),
						value:"bable"
					},
				],
				curCid:"",
				dataSelect:0,
			}
		},
		onPullDownRefresh(){
			var that = this;
			that.page=1;
			that.getContentsList(false);
			var timer = setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000)
		},
		onReachBottom() {
		    //触底后执行的方法，比如无限加载之类的
			var that = this;
			if(that.isLoad==0){
				that.loadMore();
			}
		},
		onShow(){
			var that = this;
			// #ifdef APP-PLUS
			//plus.navigator.setStatusBarStyle("dark")
			// #endif
			that.page = 1;
			if(localStorage.getItem('token')){
				that.token=localStorage.getItem('token');
				that.getContentsList(false);
			}
			if(localStorage.getItem('userinfo')){
				var userInfo = JSON.parse(localStorage.getItem('userinfo'));
				that.group = userInfo.group;
			}
		},
		onLoad() {
			var that = this;
			// #ifdef APP-PLUS || MP
			that.NavBar = that.CustomBar;
			// #endif
		},
		methods: {
			back(){
				uni.navigateBack({
					delta: 1
				});
			},
			loadMore(){
				var that = this;
				that.moreText = that.$t('global.loading');
				that.isLoad=1;
				that.getContentsList(true);
			},
			searchTag(){
				var that = this;
				var searchText = that.searchText;
				that.page=1;
				that.getContentsList();
			},
			searchClose(){
				var that = this;
				that.searchText = "";
				that.page=1;
				that.getContentsList();
			},
			toType(i){
				var that = this;
				that.type=i;
				that.page=1;
				that.moreText = that.$t('common.loadmoretxt');
				that.isLoad=0;
				that.getContentsList(false);
			},
			toSelect(i){
				var that = this;
				that.dataSelect = i;
				that.page=1;
				that.moreText = that.$t('common.loadmoretxt');
				that.isLoad=0;
				that.getContentsList(false);
			},
			getContentsList(isPage){
				var that = this;
				if(that.token==""){
					uni.showToast({
					    title: that.$t('common.plslogin'),
						icon:'none',
						duration: 1000,
						position:'bottom',
					});
					return false
				}
				var data = {
					"type":"post",
					"status":that.type
				}
				if(that.dataSelect==1){
					data.isrecommend = 1;
				}
				if(that.dataSelect==2){
					data.istop = 1;
				}
				if(that.dataSelect==3){
					data.isswiper = 1;
				}
				var page = that.page;
				if(isPage){
					page++;
				}
				that.$Net.request({
					url: that.$API.getContentsList(),
					data:{
						"searchParams":JSON.stringify(that.$API.removeObjectEmptyKey(data)),
						"limit":8,
						"page":page,
						"searchKey":that.searchText,
						"order":"created",
						"token":that.token
					},
					header:{
						'Content-Type':'application/x-www-form-urlencoded'
					},
					method: "get",
					dataType: 'json',
					success: function(res) {
						that.isLoad=0;
						that.moreText = that.$t('common.loadmoretxt');
						if(res.data.code==1){
							var list = res.data.data;
							if(list.length>0){
								var contentsList = [];
								//将自定义字段获取并添加到数据
								var curFields = that.$API.GetFields();
								for(var i in list){
									var fields = list[i].fields;
									if(fields.length>0){
										for(var j in fields){
											if(curFields.indexOf(fields[j].name)!=-1){
												list[i][fields[j].name]=fields[j].strValue;
											}
										}
									}
									contentsList.push(list[i]);
								}
								if(isPage){
									that.page++;
									that.contentsList = that.contentsList.concat(contentsList);
								}else{
									that.contentsList = contentsList;
								}
							}else{
								that.moreText = that.$t('global.nomorearticle');
								if(!isPage){
									that.contentsList = list;
								}
							}
						}
						var timer = setTimeout(function() {
							that.isLoading=1;
							clearTimeout('timer')
						}, 300)
					},
					fail: function(res) {
						that.moreText = that.$t('common.loadmoretxt');
						that.isLoad=0;
						var timer = setTimeout(function() {
							that.isLoading=1;
							clearTimeout('timer')
						}, 300)
					}
				})
			},
			toPost(){
				uni.navigateTo({
					url: '/pages/edit/articlePost'
				});
			},
			toEdit(data){
				var cid = data.cid;
				var markdown =  data.markdown;
				if(markdown==1){
					//MarkDown编辑器
					uni.navigateTo({
						url: '/pages/edit/articlePost?type=edit'+'&cid='+cid
					});
				}else{
					//富文本编辑器
					uni.navigateTo({
						url: '/pages/edit/articlePost?type=edit'+'&cid='+cid
					});
				}
			},
			subText(text,num){
				if(text.length < null){
					return text.substring(0,num)+"……"
				}else{
					return text;
				}
			},
			formatDate(datetime) {
				var datetime = new Date(parseInt(datetime * 1000));
				// 获取年月日时分秒值  slice(-2)过滤掉大于10日期前面的0
				var year = datetime.getFullYear(),
					month = ("0" + (datetime.getMonth() + 1)).slice(-2),
					date = ("0" + datetime.getDate()).slice(-2),
					hour = ("0" + datetime.getHours()).slice(-2),
					minute = ("0" + datetime.getMinutes()).slice(-2);
				//second = ("0" + date.getSeconds()).slice(-2);
				// 拼接
				var result = year + "-" + month + "-" + date + " " + hour + ":" + minute;
				// 返回
				return result;
			},
			toAudit(id,type){
				var that = this;
				var token = "";
				that.modalName=null;
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				if(type==1){
					if(that.reason==""){
						that.modalName='reject';
						that.curCid = id;
						return false
					}
				}
				var alert = that.$t('manage.contents.surepassarticle');
				if(type==1){
					alert = that.$t('manage.contents.surerejectarticle');
				}
				var data = {
					"type":type,
					"key":id,
					"token":token,
					"reason":that.reason
				}
				uni.showModal({
				    title: alert,
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.contentsAudit(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										if(type==0){
											uni.request({
												url:that.$API.SPgetwzpost(),
												method:'GET',
												data:{
													cid:id,
												},
												dataType:"json",
												success(res) {
												},
												fail() {
													setTimeout(function () {
														uni.hideLoading();
													}, 1000);
													uni.showToast({
														title: that.$t('common.networkfail'),
														icon: 'none'
													})
												}
											})
										}
				            			that.page=1;
				            			that.moreText = that.$t('common.loadmoretxt');
				            			that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
									that.reason="";
									that.curCid=0;
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			toDelete(id){
				var that = this;
				var token = "";
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"token":token
				}
				uni.showModal({
				    title: that.$t('global.suredelarticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.contentsDelete(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										uni.request({
											url:that.$API.SPwzpostremove(),
											method:'GET',
											data:{
												cid:id,
											},
											dataType:"json",
											success(res) {
											},
											fail() {
												setTimeout(function () {
													uni.hideLoading();
												}, 1000);
												uni.showToast({
													title: that.$t('common.networkfail'),
													icon: 'none'
												})
											}
										})
				            			that.page=1;
				            			that.moreText = that.$t('common.loadmoretxt');
				            			that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			addRecommend(id){
				var that = this;
				var token = "";
				
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"recommend":1,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.suresuggestarticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toRecommend(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
				            			that.getContentsList();
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			rmRecommend(id){
				var that = this;
				var token = "";
				
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"recommend":0,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.surenosuggestarticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toRecommend(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
										setTimeout(function() {
											that.getContentsList();
										}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			addTop(id){
				var that = this;
				var token = "";
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"istop":1,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.suretoparticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toTop(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			rmTop(id){
				var that = this;
				var token = "";
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"istop":0,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.surenotoparticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toTop(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			addSwiper(id){
				var that = this;
				var token = "";
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"isswiper":1,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.surerotatearticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toSwiper(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			rmSwiper(id){
				var that = this;
				var token = "";
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"key":id,
					"isswiper":0,
					"token":token
				}
				uni.showModal({
				    title: that.$t('manage.contents.surenorotatearticle'),
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				            	title: that.$t('common.loadmore')
				            });
				            that.$Net.request({
				            	url: that.$API.toSwiper(),
				            	data:data,
				            	header:{
				            		'Content-Type':'application/x-www-form-urlencoded'
				            	},
				            	method: "get",
				            	dataType: 'json',
				            	success: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: res.data.msg,
				            			icon: 'none'
				            		})
				            		if(res.data.code==1){
										that.page=1;
										that.moreText = that.$t('common.loadmoretxt');
										that.isLoad=0;
				            			setTimeout(function() {
				            				that.getContentsList();
				            			}, 1000)
				            		}
				            	},
				            	fail: function(res) {
				            		setTimeout(function () {
				            			uni.hideLoading();
				            		}, 1000);
				            		uni.showToast({
				            			title: that.$t('common.networkfail'),
				            			icon: 'none'
				            		})
				            	}
				            })
				        }
				    }
				});
			},
			toMetas(){
				uni.navigateTo({
					url: '/pages/manage/metas'
				});
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
			RadioChange(e) {
				var abcimg = e.detail.value;
				var cid = this.curCid;
				this.setFields(cid,abcimg);
			},
			setFields(id,type){
				var that = this;
				that.curCid = id;
				if(type){
					that.abcimg = type;
				}else{
					that.abcimg = "able";
				}
				if(that.modalName == null){
					that.modalName = "RadioModal";
					return false;
				}
				var token;
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token=userInfo.token;
				}
				var data = {
					"cid":id,
					"name":"abcimg",
					"strvalue":that.abcimg,
					"token":token
				}
				that.modalName = null;
				uni.showLoading({
					title: that.$t('common.loadmore')
				});
				that.$Net.request({
					url: that.$API.setFields(),
					data:data,
					header:{
						'Content-Type':'application/x-www-form-urlencoded'
					},
					method: "get",
					dataType: 'json',
					success: function(res) {
						that.modalName =  null;
						that.abcimg = "able";
						that.curCid = "";
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
						if(res.data.code==1){
							that.page=1;
							that.moreText = that.$t('common.loadmoretxt');
							that.isLoad=0;
							setTimeout(function() {
								that.getContentsList();
							}, 1000)
						}
					},
					fail: function(res) {
						that.modalName =  null;
						that.abcimg = "able";
						that.curCid = "";
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: that.$t('common.networkfail'),
							icon: 'none'
						})
					}
				})
			},
			
		}
	}
</script>